﻿@model PagedResult<BlogPostDto>
@using System.Configuration
@using EnetaMvc.Infrastructure
@using EnetaMvc.ApplicationServices.Dto
@{
	ViewBag.Title = Resources.EnetaMvc.BlogsTitle;
	Layout = "~/Views/Shared/_NewsLayout.cshtml";
}

<div class="blog-head">
	<div class="blog-head-txt">
		<h2 style="float: left"><a href="@Url.Content("~/news/blogs/posts/")">@Resources.EnetaMvc.BlogsTitle</a></h2>
		@Html.GetPager(Model, Url.Content("~/news/blogs/posts/"))
	</div>
</div>

<div class="content-blog-area">
	@for(var i=0; i < Model.Results.Count; i++)
	{
		var article = Model.Results[i];
        var firstArticleSuffix = (Model.CurrentPage == 1 && i == 0 ? "blog-first" : "");
		var commentsCountString = new MvcHtmlString("");

		if (article.Comments.Length != 0)
		{
			commentsCountString = new MvcHtmlString("<span>(" + article.Comments.Length + ")</span>");
		}
	 
	<div class="blog @firstArticleSuffix">
		<div class="blog-foto"> <a href="@Url.Content("~/Profiles/Details/" + article.CreatedById)"><img alt="@article.CreatedByUserName" src="@Html.GetProfileUrl(article.CreatedById)" width="32" height="32" /></a> </div>
		<div class="blog-txt">
			<h3><a href="@Url.Action("Details", new { id = article.Id })">@article.Title @commentsCountString</a></h3>
			<ul>
				<li>
                    <a href="@Url.Content("~/Profiles/Details/" + article.CreatedById)" style="font-weight:bold;color:#39c;">
                        @article.CreatedByUserName
                    </a>
				</li>
				<li>
                    <a href="@Url.Content("~/news/blogs/details/" + article.BlogId)" style="font-weight:bold;color:#39c;">
                        @article.BlogName
				    </a>
				</li>
				<li>@article.Created.ToShortDateString()</li>
			</ul>
			<p>@Html.StripAllHtmlTags(article.Abstract) <a class="more-info" href="@Url.Action("Details", new { id = article.Id })">@Resources.EnetaMvc.ReadMore</a></p>
			@*<ul class="tags">
				<li><a href="#">äri</a>,</li>
				<li><a href="#">ettevõtlus</a>,</li>
				<li><a href="#">sündmus</a>,</li>
				<li><a href="#">haridus</a>,</li>
				<li><a href="#">BizTalk</a></li>
			</ul>*@
		</div>
	</div>
	}
</div>

<div class="blogs-menu">
	<ul>
		<li><a href="@Url.Content("~/")">@ConfigurationManager.AppSettings["PortalName"]</a></li>
		<li>@Resources.EnetaMvc.News</li>
		<li><a href="@Url.Content("~/news/blogs/posts/")">@Resources.EnetaMvc.Blogs</a></li>		
	</ul>
	@Html.GetPager(Model, Url.Content("~/news/blogs/posts/"))
</div>
